﻿// Copyright © 2011 Vladislav Borovikov
// http://vividkit.codeplex.com/

namespace VividKit.Controls
{
	using System;
	using System.Windows;
	using Microsoft.Phone.Shell;

	public sealed class PageBarButton : PageBarItem
	{
		public PageBarButton()
			: base(new ApplicationBarIconButton(new Uri("icon.png", UriKind.Relative)) { Text = "execute" })
		{
		}

		internal ApplicationBarIconButton InternalButton { get { return (ApplicationBarIconButton)base.ApplicationBarItem; } }

		protected override void OnIconChanged(DependencyPropertyChangedEventArgs e)
		{
			var icon = e.NewValue as Uri;
			if (icon != null)
			{
				this.InternalButton.IconUri = icon;
			}
		}
	}
}